import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/register', component: () => import('@/views/register/index'), hidden: true },
  { path: '/retrieve', component: () => import('@/views/retrieve/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/main',
  //   name: 'Main',
  //   hidden: true,
  //   children: [{
  //     path: 'main',
  //     component: () => import('@/views/dashboard/index') }]
  // },

  {
    path: '/',
    component: Layout,
    redirect: '/index/1',
    name: 'index',
    meta: { title: '共享人才管理', icon: 'Share' },
    children: [
      {
        path: 'index/1',
        name: 'surplus',
        component: () => import('@/views/personnel/surplus'),
        meta: { title: '余量人才', icon: 'allowance', id: 1 }
      },
      {
        path: 'index/2',
        name: 'own',
        component: () => import('@/views/personnel/own'),
        meta: { title: '自有人才', icon: 'have', id: 2}
      },
      {
        path: 'index/3',
        name: 'all',
        component: () => import('@/views/personnel/all'),
        meta: { title: '全网人才库', icon: 'have', id: 3}
      },
      {
        path: 'post/:id',
        name: 'post/:id',
        component: () => import('@/views/personnel/post'),
        meta: { title: '添加', icon: 'tree' },
        hidden: true
      }
    ]
  },

  {
    path: '/position',
    component: Layout,
    meta: { title: '职位管理', icon: 'jobManagement' },
    children: [
      {
        path: 'index',
        name: 'positionIndex',
        component: () => import('@/views/position/index'),
        meta: { title: '查看职位', icon: 'see' }},
      {
        path: 'post',
        name: 'post',
        component: () => import('@/views/position/post'),
        meta: { title: '新增职位', icon: 'add' }},
      {
        path: 'edit',
        name: 'edit',
        component: () => import('@/views/position/post'),
        meta: { title: '职位修改', icon: 'add' },
        hidden: true
      }
    ]
  },
  {
    path: '/interview',
    component: Layout,
    meta: { title: '面试管理', icon: 'Interview' },
    children: [
      {
        path: 'index/0',
        component: () => import('@/views/interview/index'), // Parent router-view
        name: 'Menu0',
        meta: { title: '已投递', id: 0, icon: 'Delivered' }
      },
      {
        path: 'index/1',
        component: () => import('@/views/interview/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: '已沟通', id: 1, icon: 'Communicated' }
       },
      {
        path: 'index/2',
        component: () => import('@/views/interview/index'),
        name: 'Menu2',
        meta: { title: '待面试', id: 2, icon: 'Tobeinterviewed'}
      },
      {
        path: 'index/3',
        component: () => import('@/views/interview/index'),
        name: 'Menu3',
        meta: { title: '已面试', id: 3, icon: 'Interviewed' }
      }
    ]
  },
  {
    path: '/setting',
    component: Layout,
    meta: { title: '企业中心', icon: 'EnterpriseCenter' },
    children: [
      {
        path: 'index',
        component: () => import('@/views/setting/index'), // Parent router-view
        name: 'settingIndex',
        meta: { title: '认证管理', icon: 'Authentication' }},
      {
        path: 'introduce',
        component: () => import('@/views/setting/introduce'),
        name: 'introduce',
        meta: { title: '公司介绍', icon: 'Companyintroduction' }
      },
      {
        path: 'business',
        component: () => import('@/views/setting/business'),
        name: 'business',
        meta: { title: '业务介绍', icon: 'Businessintroduction' }
      },
      {
        path: 'account',
        component: () => import('@/views/setting/account'),
        name: 'account',
        meta: { title: '账户管理', icon: 'Accountmanagement' }
      },
      {
        path: 'security',
        component: () => import('@/views/setting/security'),
        name: 'security',
        meta: { title: '安全中心', icon: 'SafetyCenter' }
      },
      {
        path: 'service',
        component: () => import('@/views/setting/service'),
        name: 'service',
        meta: { title: '专属客服', icon: 'Customerservice' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  mode: 'hash',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
